// Compiled with DACGenerator 1.5.3.24758, by DESTRA\jon on 22/10/2007 1:04:13 PM
namespace Destra.Common.Caching.Queries
{
    
    
    [System.ComponentModel.DataObjectAttribute()]
    public partial class GetCacheTablesForChangeNotification : Destra.Common.DataAccess.DACBase
    {
        
        private System.Data.SqlClient.SqlConnection m_userConnection;
        
        #region Command Timeout Field
        private int m_commandTimeout = 30;
        #endregion
        
        #region Command Text Field
        private string m_commandText = "SELECT [tableName]\r\n      ,[notificationCreated]\r\n      ,[changeId]\r\n  FROM [dbo]" +
            ".[AspNet_SqlCacheTablesForChangeNotification]";
        #endregion
        
        public GetCacheTablesForChangeNotification()
        {
        }
        
        public GetCacheTablesForChangeNotification(System.Data.SqlClient.SqlConnection connection)
        {
            this.m_userConnection = connection;
        }
        
        public override System.Data.SqlClient.SqlConnection Connection
        {
            get
            {
                if ((this.m_userConnection == null))
                {
                    return base.Connection;
                }
                else
                {
                    return this.m_userConnection;
                }
            }
        }
        
        #region Command Timeout Property
        public int CommandTimeout
        {
            get
            {
                return m_commandTimeout;
            }
            set
            {
                m_commandTimeout = value;
            }
        }
        #endregion
        
        #region Command Text Property
        public string CommandText
        {
            get
            {
                return m_commandText;
            }
            set
            {
                m_commandText = value;
            }
        }
        #endregion
        
        protected override string ConnectionStringName
        {
            get
            {
                return "cacheConnection";
            }
        }
        
        #region Concrete GetCommand Method
        public System.Data.SqlClient.SqlCommand GetCommand(System.Data.SqlClient.SqlConnection connection)
        {
            System.Data.SqlClient.SqlCommand command = new System.Data.SqlClient.SqlCommand();
            command.CommandTimeout = CommandTimeout;
            command.Connection = connection;
            command.CommandText = CommandText;
            if (command.CommandText.ToLowerInvariant().Contains("@@identity"))
            {
                throw new System.ArgumentException("You cannot use @@IDENTITY in any query, please use SCOPE_IDENTITY() instead.");
            }
            command.CommandType = System.Data.CommandType.Text;
            return command;
        }
        #endregion
        
        #region Execute reader methods
        public GetCacheTablesForChangeNotification.Reader ExecuteReader(bool singleRow)
        {
            System.Data.SqlClient.SqlCommand command = null;
            System.Data.SqlClient.SqlDataReader reader = null;
            System.Diagnostics.Stopwatch timer = new System.Diagnostics.Stopwatch();
            try
            {
				if (this.Connection.State == System.Data.ConnectionState.Closed)
				{
					this.Connection.Open();
				}
                command = this.GetCommand(this.Connection);
                timer.Start();
				if (singleRow)
				{
					reader = command.ExecuteReader(System.Data.CommandBehavior.SingleRow);
				}
				else
				{
					reader = command.ExecuteReader();
				}
                return new GetCacheTablesForChangeNotification.Reader(reader);
            }
            finally
            {
				if (command != null)
				{
					command.Dispose();
				}
                timer.Stop();
                Destra.Common.Logging.Logger.Log(Destra.Common.Logging.Category.DataAccess, System.Diagnostics.TraceEventType.Information, Destra.Common.Logging.Priority.Normal, string.Format("{0} execution time {1}s", "GetCacheTablesForChangeNotification", timer.Elapsed.TotalSeconds));
            }
        }
        #endregion
        
        #region A static method to return an external strongly typed Entity object
        /// <summary>
        /// A static method to return an external strongly typed Entity object
        /// </summary>
        [System.ComponentModel.DataObjectMethodAttribute(System.ComponentModel.DataObjectMethodType.Select)]
        public static Destra.Common.Caching.Queries.GetCacheTablesForChangeNotification.Entity ReadEntity()
        {
            Destra.Common.Caching.Queries.GetCacheTablesForChangeNotification dac = new Destra.Common.Caching.Queries.GetCacheTablesForChangeNotification();
            Destra.Common.Caching.Queries.GetCacheTablesForChangeNotification.Reader reader = null;
            try
            {
				reader = dac.ExecuteReader(true);
                for (; reader.Read(); )
                {
                    Destra.Common.Caching.Queries.GetCacheTablesForChangeNotification.Entity entity = new Destra.Common.Caching.Queries.GetCacheTablesForChangeNotification.Entity();
                    entity.tableName = reader.tableName;
                    entity.notificationCreated = reader.notificationCreated;
                    entity.changeId = reader.changeId;
                    return entity;
                }
            }
            finally
            {
				if (reader != null)
				{
					reader.Close();
					(reader as System.IDisposable).Dispose();
				}
				if (dac != null)
				{
					(dac as System.IDisposable).Dispose();
				}
            }
            return null;
        }
        #endregion
        
        #region A static method to return an external strongly typed Entities object array
        /// <summary>
        /// A static method to return an external strongly typed Entities object array
        /// </summary>
        [System.ComponentModel.DataObjectMethodAttribute(System.ComponentModel.DataObjectMethodType.Select)]
        public static Destra.Common.Caching.Queries.GetCacheTablesForChangeNotification.Entity[] ReadEntities()
        {
            System.Collections.Generic.List<Destra.Common.Caching.Queries.GetCacheTablesForChangeNotification.Entity> entities = new System.Collections.Generic.List<Destra.Common.Caching.Queries.GetCacheTablesForChangeNotification.Entity>();
            Destra.Common.Caching.Queries.GetCacheTablesForChangeNotification dac = new Destra.Common.Caching.Queries.GetCacheTablesForChangeNotification();
            Destra.Common.Caching.Queries.GetCacheTablesForChangeNotification.Reader reader = null;
            try
            {
				reader = dac.ExecuteReader(false);
                for (; reader.Read(); )
                {
                    Destra.Common.Caching.Queries.GetCacheTablesForChangeNotification.Entity entity = new Destra.Common.Caching.Queries.GetCacheTablesForChangeNotification.Entity();
                    entity.tableName = reader.tableName;
                    entity.notificationCreated = reader.notificationCreated;
                    entity.changeId = reader.changeId;
                    entities.Add(entity);
                }
            }
            finally
            {
				if (reader != null)
				{
					reader.Close();
					(reader as System.IDisposable).Dispose();
				}
				if (dac != null)
				{
					(dac as System.IDisposable).Dispose();
				}
            }
            return entities.ToArray();
        }
        #endregion
        
        #region Entity Class
        [System.SerializableAttribute()]
        public class Entity
        {
            
            private string m_tableName;
            
            private System.DateTime m_notificationCreated;
            
            private int m_changeId;
            
            public string tableName
            {
                get
                {
                    return this.m_tableName;
                }
                set
                {
                    this.m_tableName = value;
                }
            }
            
            public System.DateTime notificationCreated
            {
                get
                {
                    return this.m_notificationCreated;
                }
                set
                {
                    this.m_notificationCreated = value;
                }
            }
            
            public int changeId
            {
                get
                {
                    return this.m_changeId;
                }
                set
                {
                    this.m_changeId = value;
                }
            }
        }
        #endregion
        
        #region Strongly typed Data Reader class
        public partial class Reader : Destra.Common.DataAccess.ReaderBase
        {
            
            public Reader(System.Data.SqlClient.SqlDataReader reader) : 
                    base(reader)
            {
            }
            
            public string tableName
            {
                get
                {
                    return ((string)(this["tableName"]));
                }
            }
            
            public System.DateTime notificationCreated
            {
                get
                {
                    return ((System.DateTime)(this["notificationCreated"]));
                }
            }
            
            public int changeId
            {
                get
                {
                    return ((int)(this["changeId"]));
                }
            }
        }
        #endregion
    }
}
